package cn.ljy.authority.model;

import cn.ljy.common.model.BaseModel;
import cn.ljy.common.model.validate.UpdateWorkValidation;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@ApiModel(value = "微信用户信息")
@Data
@EqualsAndHashCode(callSuper = false, of = {"id"})
@NoArgsConstructor
public class SysWechatUser extends BaseModel {

    @NotNull(groups = UpdateWorkValidation.class, message = "id不能为空")
    private Long id;

    @NotNull(message = "用户ID不能为空")
    private SysUser user; // 关联用户对象
    private Long userId; // 对应数据库 user_id

    @NotBlank(message = "微信openid不能为空")
    @Length(max = 100, message = "openid长度不能超过 {max} 个字符")
    private String openId; // 对应数据库 open_id

    @Length(max = 100, message = "unionid长度不能超过 {max} 个字符")
    private String unionId; // 对应数据库 union_id

    @Length(max = 100, message = "昵称长度不能超过 {max} 个字符")
    private String nickname; // 对应数据库 nickname

    @Length(max = 255, message = "头像URL长度不能超过 {max} 个字符")
    private String avatarUrl; // 对应数据库 avatar_url

    @Length(max = 255, message = "session_key长度不能超过 {max} 个字符")
    private String sessionKey; // 对应数据库 session_key

    @NotNull(message = "创建时间不能为空")
    private java.util.Date createTime; // 对应数据库 create_time

    private java.util.Date updateTime; // 对应数据库 update_time

    // 非数据库字段（可选）
    private Integer roleNumber;
    private Integer permissionNumber;

    // 用于接收前端数据
    private Integer[] roleIds;

    public SysWechatUser(Long id) {
        this.id = id;
    }

}